#include<iostream>
using namespace std;

#include"task141011.h"

	Array::Array() : actualsize(0), size(1), data(new int[1]) {}
		
	Array::Array(Array const & a) : size(a.size), actualsize(a.actualsize), data(new int[size]) {
		for (size_t i = 0; i < actualsize; i++)
			data[i] = a.data[i];
	}
	
	Array::Array(size_t size) : size(size ? size : 1), actualsize(size), data(new int[size ? size : 1]) {}
	
	Array& Array::operator= (Array const & a) {
		Array temp(a);
		swap(size, temp.size);
		swap(actualsize, temp.actualsize);
		swap(data, temp.data);
		return *this;
	}
	
	Array::~Array() {
		delete[] data;
	}
	
	void Array::push_back(int i) {
		if (actualsize == size) increaseSize(size << 1);
		data[actualsize++] = i;
	}
	
	bool Array::getIOB() {
		return IOB;
	}
	
	int Array::get(size_t index) const {
		if (index >= actualsize) {			
			IOB = true;
			return 0;
		}
		else
			IOB = false;
		return data[index];
	}
	
	size_t Array::get_size() const {
		return actualsize;
	}
	
	void Array::set(size_t index, int val) {
		if (index >= size)
			increaseSize(index + 1);
		if (index >= actualsize) {
			actualsize = index + 1;
			IOB = true;
		}
		else
			IOB = false;
		data[index] = val;
	}
			
	void Array::increaseSize(size_t upto) {
		if (upto > size) {
			int * temp = new int[upto];
			for(size_t i = 0; i < actualsize; i++)
				temp[i] = data[i];
			delete[] data;
			data = temp;
			size = upto;
		}
	}
		

bool Array::IOB = false;

int main() {
	Array a(10);
	cout <<  "Index out of bounds " << (Array::getIOB() ? "TRUE" : "FALSE") << endl;	
	a.set(15,4);
	cout <<  "Index out of bounds " << (Array::getIOB() ? "TRUE" : "FALSE") << endl;	
	cout << a.get(15) << endl;
	cout <<  "Index out of bounds " << (Array::getIOB() ? "TRUE" : "FALSE") << endl;	
	cout << a.get(100500) << endl;
	cout <<  "Index out of bounds " << (Array::getIOB() ? "TRUE" : "FALSE") << endl;	
	return 0;
}